package com.soar.tbox.protocol;

import com.soar.tbox.CommandStorage;
import com.soar.tbox.DisplayHandler;
import com.soar.tbox.Messenger;
import com.soar.tbox.bean.Command;
import com.soar.tbox.util.LogUtil;

/**
 * 打开空调启指令处理
 * @author songjunjie
 *
 */
public class Protocol0302 implements Protocol {
	/**
	 * 指令名. 车辆控制类_开启空调
	 */
	private static final String NAME = "0302";

	private Command cmd = null;
	private String serialNum = null;
	public Protocol0302(Command cmd , String serialNum) {
		this.cmd = cmd;
		this.serialNum = serialNum;
	}

	@Override
	public void handle() {
		DisplayHandler.show("执行开启空调指令");
		Command resultCommand = CommandStorage.getCommand(NAME);
		resultCommand.setSerialNum(serialNum);
		try {
			Messenger messenger = new Messenger();
			messenger.send(resultCommand, false);
			DisplayHandler.show("操作成功");
		} catch (Exception e) {
			LogUtil.error("", e);
			e.printStackTrace();
			DisplayHandler.show("发成异常" + e.getMessage());
		}
	}
}
